package javaapplication1;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * TODO: przetestowac dzialanie z serwerem zaimplementowac http DELETE
 * references:
 * http://www.codejava.net/java-se/networking/an-http-utility-class-to-send-getpost-request
 */
public class Klient extends javax.swing.JFrame {

    public Klient() {
        tcpListeners = new HashMap<Subscription, TCPListener>();
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jPanel1 = new javax.swing.JPanel();
        jTextFieldAddress = new javax.swing.JTextField();
        jTextFieldPort = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextAreaLog = new javax.swing.JTextArea();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTextAreaDataRecieved = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldCommand = new javax.swing.JTextField();
        jButtonPOST = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Klient");

        jTextFieldAddress.setText("127.0.0.1");

        jTextFieldPort.setText("8080");

        jLabel4.setText("Address:");

        jLabel5.setText("Port:");

        jLabel7.setText("Monitor HTTP Server Address:");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldAddress, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldPort)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(4, 4, 4)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(121, 121, 121))
        );

        jLabel3.setText("Status:");

        jTextAreaLog.setColumns(20);
        jTextAreaLog.setFont(new java.awt.Font("Monospaced", 0, 11)); // NOI18N
        jTextAreaLog.setLineWrap(true);
        jTextAreaLog.setRows(5);
        jTextAreaLog.setWrapStyleWord(true);
        jScrollPane1.setViewportView(jTextAreaLog);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 406, Short.MAX_VALUE)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel3)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 178, Short.MAX_VALUE))
        );

        jTextAreaDataRecieved.setColumns(20);
        jTextAreaDataRecieved.setFont(new java.awt.Font("Monospaced", 0, 11)); // NOI18N
        jTextAreaDataRecieved.setLineWrap(true);
        jTextAreaDataRecieved.setRows(5);
        jTextAreaDataRecieved.setWrapStyleWord(true);
        jScrollPane2.setViewportView(jTextAreaDataRecieved);

        jLabel2.setText("Data Recieved from Sensor(s) (TCP):");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addComponent(jLabel2)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel6.setText("Command:");

        jTextFieldCommand.setText("subscribe google.mainframe1.com cpu-usage");

        jButtonPOST.setText("POST");
        jButtonPOST.setAlignmentY(0.0F);
        jButtonPOST.setMargin(new java.awt.Insets(0, 0, 0, 0));
        jButtonPOST.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonPOSTActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextFieldCommand)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jButtonPOST, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jTextFieldCommand, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel6)
                .addComponent(jButtonPOST, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(184, 184, 184)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    //request resource metric from monitor
    private void jButtonPOSTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPOSTActionPerformed
        String text = jTextFieldCommand.getText().trim();
        StringTokenizer st = new StringTokenizer(text);
        //if command subscribe 
        if (st.countTokens() == 3) {
            if (text.startsWith("subscribe") || text.startsWith("SUBSCRIBE")) {
                try {
                    st.nextToken(); //drop unusefull "subscribe token"
                    String resourceId = st.nextToken();
                    String metric = st.nextToken();
                    //send HTTP POST requesting creation of subscription
                    //example: subscribe host2.edu.pl cpu-usage
                    Subscription subscription = new Subscription(resourceId, metric);
                    jTextAreaLog.append("subscribing to:" + resourceId + " " + metric + "\n");
                    //send HTTP POST to monitor http server and recieve response with InputStream
                    String recievedSubscriptionURL = POSTSubscribtion(resourceId, metric);//"http://localhost:8080/subscriptions/12";
                    
                        
                    
                    //old:InputStream inputStream = sendPostRequest("http://localhost:8080/subscriptions", parametersForPost);
                    //save subscription url
                    subscription.SubscriptionURL = recievedSubscriptionURL;
                    jTextAreaLog.append("recieved subscribtion string: " + recievedSubscriptionURL + "\n");
                    //send HTTP GET requesting address and port for TCP connection of wanted resource&metric
                    String[] response = GETLocation(recievedSubscriptionURL);

                    for (String line : response) {
                        if (line.startsWith("<host>")) {
                            Pattern p = Pattern.compile("<host>(.*)</host>", Pattern.DOTALL);
                            Matcher matcher = p.matcher(line);
                            if (matcher.matches()) {
                                subscription.mappedAddress = matcher.group(1);
                            }

                        } else if (line.startsWith("<port>")) {
                            Pattern p = Pattern.compile("<port>(.*?)</port>", Pattern.DOTALL);
                            Matcher matcher = p.matcher(line);

                            if (matcher.matches()) {
                                subscription.mappedPort = Integer.parseInt(matcher.group(1).trim());
                            }
                        }
                    }

                    //start listening on given tcp port
                    TCPListener tcpListener = new TCPListener(subscription.mappedAddress, subscription.mappedPort, resourceId, this);
                    tcpListener.start();
                    tcpListeners.put(subscription, tcpListener);
                } catch (Exception ex) {
                    jTextAreaLog.append(ex + "\n");
                }
                //if command disconnect - send HTTP DELETE <url of the subscribtion> 
            } else if (text.startsWith("disconnect") || text.startsWith("DISCONNECT")) {
                //send HTTP DELETE
                //TODO: zaimplementować wysyłanie HTTP DELETE

                try {
                    st.nextToken(); //drop unusefull "disconnect token"
                    String resourceId = st.nextToken();
                    String metric = st.nextToken();
                    URL url;
                    Iterator<Subscription> it = tcpListeners.keySet().iterator();
                    Subscription subscription = null;
                    while (it.hasNext()) {
                        subscription = it.next();
                        if (subscription.resourceAddress.equals(resourceId) && subscription.metric.equals(metric)) {
                            jTextAreaLog.append("Disconnect from " + resourceId + " " + metric + " successfull." + "\n");
                            url = new URL(subscription.SubscriptionURL);
                            HttpURLConnection httpCon = (HttpURLConnection) url.openConnection();
                            httpCon.setDoOutput(true);
                            httpCon.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                            httpCon.setRequestMethod("DELETE");
                            httpCon.connect();
                            int responseCode = httpCon.getResponseCode();
                            jTextAreaLog.append("Response Code: "+responseCode);
                            tcpListeners.get(subscription).stopWork();
                            break;
                        }
                    }
                    if (subscription != null) {
                        tcpListeners.remove(subscription);
                    }
                } catch (Exception ex) {
                    jTextAreaLog.append(ex + "\n");
                }
            } else {
                jTextAreaLog.append("Error: unknown command" + "\n");
                jTextAreaLog.append("Use commands:" + "\n");
                jTextAreaLog.append("subscribe <resourceAddress> <metric>" + "\n");
                jTextAreaLog.append("disconnect <resourceAddress> <metric>" + "\n");
            }
        } else {
            jTextAreaLog.append("Syntax error: uncomplete command" + "\n");
            jTextAreaLog.append("Use commands:" + "\n");
            jTextAreaLog.append("- subscribe <resourceAddress> <metric>" + "\n");
            jTextAreaLog.append("- disconnect <resourceAddress> <metric>" + "\n");
        }
    }//GEN-LAST:event_jButtonPOSTActionPerformed
    public String POSTSubscribtion(String hostName, String metric) {
        try {
            Map<String, String> params = new HashMap<String, String>();
            String addressIp = jTextFieldAddress.getText().trim();
            String port = jTextFieldPort.getText().trim();
            String requestURL = "http://" + addressIp + ":" + port + "/subscribtions";
            params.put("resourceid", hostName);
            params.put("metric", metric);
            InputStream is = sendPostRequest(requestURL, params);
            String[] response = parseMultipleLinesRespone(is);
            String s = "";
            for (String line : response) {
                System.out.println(line);
                s += line;
            }
            return s;
        } catch (Exception ex) {
            jTextAreaLog.append("Could not connect to server " + jTextFieldAddress.getText().trim() + ":" +jTextFieldPort.getText() +" - not responding\n");
            return null;
        }
    }

    public String[] GETLocation(String url) {
        try {
            String requestURL = url;
            InputStream is = sendGetRequest(requestURL);
            String[] response = parseMultipleLinesRespone(is);
            return response;
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }

    //--------------------------------------   
    //sends HTTP GET to server and returns open stream with HTTP response from this server.
    public static InputStream sendGetRequest(String requestURL) throws IOException {
        URL url = new URL(requestURL);
        URLConnection urlConn = url.openConnection();
        urlConn.setUseCaches(false);

        urlConn.setDoInput(true);    // true indicates the server returns response
        urlConn.setDoOutput(false);    // false indicates GET request

        return urlConn.getInputStream();
    }

    //sends HTTP POST to server and returns open stream with HTTP response from this server
    public static InputStream sendPostRequest(String requestURL, Map<String, String> params) throws IOException {
        URL url = new URL(requestURL);
        URLConnection urlConn = url.openConnection();
        urlConn.setUseCaches(false);

        urlConn.setDoInput(true);    // true indicates the server returns response

        StringBuffer requestParams = new StringBuffer();

        if (params != null && params.size() > 0) {

            urlConn.setDoOutput(true);    // true indicates POST request

            // creates the params string, encode them using URLEncoder
            Iterator<String> paramIterator = params.keySet().iterator();
            while (paramIterator.hasNext()) {
                String key = paramIterator.next();
                String value = params.get(key);
                requestParams.append(URLEncoder.encode(key, "UTF-8"));
                requestParams.append("=").append(URLEncoder.encode(value, "UTF-8"));
                requestParams.append("&");
            }
            // sends POST data
            OutputStreamWriter writer = new OutputStreamWriter(urlConn.getOutputStream());
            writer.write(requestParams.toString());
            writer.flush();
        }
        return urlConn.getInputStream();
    }

    //Returns an array of lines from the server's response.
    public static String[] parseMultipleLinesRespone(InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        ArrayList<String> response = new ArrayList<String>();

        String line = "";
        while ((line = reader.readLine()) != null) {
            response.add(line);
        }
        reader.close();

        return (String[]) response.toArray(new String[0]);
    }

    //Returns only one line (first line) from the server's response.
    public static String parseSingleLineRespone(InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String response = reader.readLine();
        reader.close();

        return response;
    }

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;


                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Klient.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Klient.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Klient.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Klient.class
                    .getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Klient().setVisible(true);
            }
        });
    }

    //prints out status messages
    public void printLog(String msg) {
        jTextAreaLog.append(msg + "\n");
    }

    //prints out data recieved from sensors
    public void printData(String data) {
        jTextAreaDataRecieved.append(data + "\n");
    }
    boolean connected = false;
    HashMap<Subscription, TCPListener> tcpListeners;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonPOST;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextArea jTextAreaDataRecieved;
    private javax.swing.JTextArea jTextAreaLog;
    private javax.swing.JTextField jTextFieldAddress;
    private javax.swing.JTextField jTextFieldCommand;
    private javax.swing.JTextField jTextFieldPort;
    // End of variables declaration//GEN-END:variables
}
